package com.example.controller;


import com.example.dto.RoleStatusDto;
import com.example.dto.UserStatusDto;
import com.example.service.RoleService;
import com.example.utils.ResponseResult;
import com.example.utils.SecurityUtils;
import com.example.vo.MenuVo;
import com.example.vo.RoutersVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.List;

@RestController
@RequestMapping("system/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("list")
    public ResponseResult getList(@PathParam("pageNum") int pageNum, @PathParam("pageSize") int pageSize, @PathParam("roleName") String roleName, @PathParam("status") String status){
        return roleService.getList(pageNum,pageSize,roleName,status);
    }

    @PutMapping("changeStatus")
    public ResponseResult changeStatus(@RequestBody RoleStatusDto roleStatusDto){
        return roleService.changeStatus(roleStatusDto);
    }

    @GetMapping("/{id}")
    public ResponseResult getRole(@PathVariable Long id){
        return ResponseResult.okResult(roleService.getById(id));
    }

    @DeleteMapping("/{ids}")
    public ResponseResult deleteRoles(@PathVariable List<Long> ids){
        return ResponseResult.okResult(roleService.removeByIds(ids));
    }


}
